import { defineStore } from 'pinia'
// 第一个参数模块名称（key)，
export const useDemoStore = defineStore('demo', {
  persist: {
    enabled: true, //开启缓存
    strategies: [
      {
        // 缓存的模块名称
        key: "demo",
        // 保存位置，默认保存在sessionStorage
        storage: localStorage,
        // 缓存哪些状态
        // paths: ["state",'token']
      }
    ]
  },
  state: () => {
    return {
      state: false,
      token: '',
      UserGroupName: '',
      type: ''
    }
  },
  getters: {},
  actions: {
    changeState(newState) {
      this.state = newState;
    },
    changeToken(newToken) {
      this.token = newToken;
    },
    changeName(newName) {
      this.UserGroupName = newName;
    },
    changeType(newType) {
      this.type = newType
    }
  }
})